package com.senior.sendmessage.service.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.senior.sendmessage.entity.CalendarResultDTO;
import com.senior.sendmessage.service.CalendarService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author baijiliang
 */
@Service
public class CalendarServiceImpl implements CalendarService {
    @Value("${key.calendarKey}")
    private String calendarKey;
    @Value("${key.calendarUrl}")
    private String calendarUrl;

    @Override
    public CalendarResultDTO getCalendar(String date) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("key", calendarKey);
        map.put("date", date);
        map.put("detail", 1);
        String result = HttpUtil.get(calendarUrl, map);
        return JSONUtil.toBean(result, CalendarResultDTO.class);
    }

    @Override
    public String isCalendar(String statusDesc) {
        switch (statusDesc) {
            case "工作日":
                return "需要上班！";
            case "节假日":
                return "可以放假！";
            case "周末":
                return "正常休息！";
            default:
                return "不知道什么日子！";
        }
    }
}
